package so.hands.xam.core;

import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;

/** 
 * @ClassName: SeleniumServerController  
 * @Description: TODO(selenium服务控制器)
 * @author: zhuxiaofeng
 * @date:2012-10-25 上午08:28:06   
 */ 
public class SeleniumServerController {

	private SeleniumServer seleniumServer;
	private static RemoteControlConfiguration rcc;
	
	public SeleniumServerController() throws Exception{
		RemoteControlConfiguration rcc = new RemoteControlConfiguration();
		SeleniumServerController.rcc = rcc;
	}
	
	
	/**
	 * @Description: 无代理启动
	 */
	public void startServer(int serverPort) throws Exception{
		rcc.setPort(serverPort);
		this.seleniumServer = new SeleniumServer(rcc);
		seleniumServer.start();
	}
	
	/**
	 * @Description: 配置代理启动
	 */
	public void startServer(int serverPort,int proxyhost,int proxyPort) throws Exception{
		rcc.setPort(serverPort);
		this.seleniumServer = new SeleniumServer(rcc);
		seleniumServer.start();
	}
	
	public void stopServer(){
		seleniumServer.stop();
	}

	public void setSeleniumServer(SeleniumServer seleniumServer) {
		this.seleniumServer = seleniumServer;
	}

	public SeleniumServer getSeleniumServer() {
		return seleniumServer;
	}

	public void setRcc(RemoteControlConfiguration rcc) {
		SeleniumServerController.rcc = rcc;
	}

	public static RemoteControlConfiguration getRcc() {
		return rcc;
	}
}
